﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Reflection;

namespace UnrealDebugger
{
    // Layout Management

    partial class UnrealDebuggerIDE
    {
        void LoadLayout()
        {
            try
            {
                string layoutFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "UnrealDebugger.layout");

                if (File.Exists(layoutFile))
                {
                    dockPanelDebugger.LoadFromXml(layoutFile, _deserializeDockContent);
                }
                else
                {
                    Assembly assembly = typeof(UnrealDebuggerIDE).Assembly;
                    Stream layoutStream = assembly.GetManifestResourceStream("UnrealDebugger.Resources.Default.layout");
                    dockPanelDebugger.LoadFromXml(layoutStream, _deserializeDockContent);
                }
            }
            catch (Exception e)
            {
                ExceptionMessageBox msgBox = new ExceptionMessageBox(e);
                msgBox.ShowDialog();
            }
        }

        void SaveLayout()
        {
            try
            {
                string layoutFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "UnrealDebugger.layout");
                dockPanelDebugger.SaveAsXml(layoutFile);
            }
            catch (Exception e)
            {
                ExceptionMessageBox msgBox = new ExceptionMessageBox(e);
                msgBox.ShowDialog();
            }
        }
    }
}
